package com.ruoyi.parttime.chat.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.parttime.chat.domain.ChatService;
import com.ruoyi.parttime.chat.service.IChatServiceService;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 客服聊天Controller
 *
 * @author ruoyi
 * @date 2024-05-11
 */
@RestController
@RequestMapping("/system/service")
public class ChatServiceController extends BaseController {
    @Autowired
    private IChatServiceService chatServiceService;

    /**
     * 查询客服列表
     */
    @GetMapping
    public AjaxResult serviceInfo() {
        return success(chatServiceService.selectServiceInfo());
    }

    /**
     * 更具客服id查询已聊天的客户列表
     */
    @GetMapping("/client/{userId}")
    public AjaxResult clientList(@PathVariable("userId")String userId){
        return AjaxResult.success(chatServiceService.selectChatUserListById(userId));
    }

    /**
     * 导出客服聊天列表
     */
//    @PreAuthorize("@ss.hasPermi('common:service:export')")
//    @Log(title = "客服聊天", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, ChatService chatService) {
//        List<ChatService> list = chatServiceService.selectChatServiceList(chatService);
//        ExcelUtil<ChatService> util = new ExcelUtil<ChatService>(ChatService.class);
//        util.exportExcel(response, list, "客服聊天数据");
//    }

    /**
     * 获取客服聊天记录
     */
//    @PreAuthorize("@ss.hasPermi('common:service:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(chatServiceService.selectChatServiceById(id));
    }

    /**
     * 新增聊天记录
     */
//    @PreAuthorize("@ss.hasPermi('common:service:add')")
    @Log(title = "客服聊天", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChatService chatService) {
        return toAjax(chatServiceService.insertChatService(chatService));
    }

    /**
     * 修改客服聊天
     */
//    @PreAuthorize("@ss.hasPermi('common:service:edit')")
//    @Log(title = "客服聊天", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody ChatService chatService) {
//        return toAjax(chatServiceService.updateChatService(chatService));
//    }

    /**
     * 删除客服聊天
     */
//    @PreAuthorize("@ss.hasPermi('common:service:remove')")
//    @Log(title = "客服聊天", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{ids}")
//    public AjaxResult remove(@PathVariable Long[] ids) {
//        return toAjax(chatServiceService.deleteChatServiceByIds(ids));
//    }
}
